import { getCurrentInstance } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import useMainStore from '@/stores/modules/main'

import { storeToRefs } from 'pinia'

export type { FormInstance } from 'ant-design-vue'

/**
 * @method  导出全局公用对象
 */
export default function useGlobal() {
  /**当前组件实例 */
  const { proxy } = getCurrentInstance()!

  /**全局路由对象 */
  const router = useRouter()

  /**当前路由对象 */
  const route = useRoute()

  const mainStore = useMainStore()

  return {
    proxy,

    route,
    router,

    mainStore,

    storeToRefs,
  }
}
